#define _GNU_SOURCE
#include <stdio.h>

#include "ipc.h"

/*
return
	0 - socket secure
	else not
*/
int checkSocketSecurity( int socket ){
	
	struct ucred peer;
	socklen_t peerSize;
	
	//get remote peer uid and gid
	peerSize = sizeof( peer );
	if( getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &peer, &peerSize) ){
		perror( "getsockopt" );
		return -1;
	}
	
	//if remote peer user or group is root
	//if( !peer.uid || !peer.gid ) return 0;
	
	//only root
	if( !peer.uid ) return 0;
	
	return 1;
}
